(library (templates debug)
  (export debug-table)
  (import
   (except (rnrs base) let-values)
   (only (guile)
         lambda* λ
         error
         display
         with-output-to-string)
   ;; standard web library
   (web request)
   (web response)
   (web uri)
   (prefix (logging) log:)))


(define debug-table
  (λ (request body)
    `((h1 "hello world!")
      (table
       (tr (th "header") (th "value"))
       ;; splice in all request headers
       ,@(map (lambda (pair)
                `(tr (td (tt ,(with-output-to-string
                                (lambda () (display (car pair))))))
                     (td (tt ,(with-output-to-string
                                (lambda ()
                                  (write (cdr pair))))))))
              (request-headers request))))))
